<template>
	<view class="home">
		<view class="top">
		</view>
		<view class="top-nav">我的</view>
		<view class="content">
			<view class="content-info">
				<view class="content-info-item border">
					<view class="content-info-item-left">
						<u-image src="@/static/my/avatar.png" width="132rpx" height="132rpx"></u-image>
					</view>
					<view class="content-info-item-right">
						<text class="name">{{info.nickname}}</text>
					</view>
				</view>
				<view class="content-info-item border">
					<view class="content-info-item-left">
						性别：
					</view>
					<view class="content-info-item-right">
						<text>男</text>
					</view>
				</view>
				<view class="content-info-item border">
					<view class="content-info-item-left">
						电话：
					</view>
					<view class="content-info-item-right">
						<text>{{info.mobile}}</text>
					</view>
				</view>
				<view class="content-info-item">
					<view class="content-info-item-left">
						部门：
					</view>
					<view class="content-info-item-right">
						<text>{{info.deptName}}</text>
					</view>
				</view>
			</view>
			<view class="pws-box" @click="toPage('/pages/my/pwd')">
				<view>修改密码</view>
				<u-icon name="arrow-right" size="24"></u-icon>
			</view>
			<view class="logout" @click="logoutShow = true">
				退出登录
			</view>
		</view>
		<u-modal v-model="logoutShow" content="是否退出登录？" show-cancel-button @confirm="logout()"
			confirm-color="#3068E7"></u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				logoutShow: false,
				info: {}
			}
		},
		onLoad() {
			this.userInfo()
		},
		methods: {
			userInfo() {
				this.$u.api.userInfo().then(res => {
					this.info = res
				})
			},
			toPage(page) {
				uni.navigateTo({
					url: page
				})
			},
			logout() {
				uni.removeStorageSync('info');
				uni.removeStorageSync('token');
				uni.reLaunch({
					url: '/pages/login/index'
				})
			}
		}
	}
</script>
<style>
	page {
		background-color: #F5F7FA;
	}
</style>
<style lang="scss" scoped>
	.home {
		position: relative;

		.top-nav {
			position: absolute;
			left: 0;
			top: 103rpx;
			width: 100%;
			text-align: center;
			font-weight: 500;
			font-size: 36rpx;
			color: #FFFFFF;
		}

		.top {
			background: url('@/static/my/bg.png');
			width: 100%;
			height: 326rpx;
			background-size: cover;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 112rpx 30rpx 150rpx;
		}

		.content {
			position: absolute;
			left: 0;
			top: 243rpx;
			margin: 0 28rpx;

			.content-info {
				background: url('@/static/my/bg1.png');
				height: 540rpx;
				width: 694rpx;
				background-size: cover;
				padding: 0 37rpx;

				.content-info-item {
					display: flex;
					align-items: center;
					padding: 35rpx 0;

					.content-info-item-left {
						width: 155rpx;
						font-weight: 400;
						font-size: 28rpx;
						color: #333333;
					}

					.content-info-item-right {
						font-weight: 400;
						font-size: 28rpx;
						color: #333333;

						.name {
							font-weight: 600;
							font-size: 36rpx;
							color: #333333;
							line-height: 50rpx;
						}
					}
				}

				.border {
					border-bottom: 1rpx solid #E6E6E6;
				}
			}

			.pws-box {
				display: flex;
				align-items: center;
				justify-content: space-between;
				width: 694rpx;
				height: 110rpx;
				background: #FFFFFF;
				border-radius: 16rpx;
				font-weight: 400;
				font-size: 28rpx;
				color: #333333;
				margin: 28rpx 0;
				padding: 0 48rpx;
			}

			.logout {
				width: 694rpx;
				line-height: 110rpx;
				text-align: center;
				background: #FFFFFF;
				border-radius: 16rpx;
				font-weight: 400;
				font-size: 28rpx;
				color: #3068E7;
			}

		}
	}
</style>